<!DOCTYPE html>
<html>
<head>
    <title>个人信息</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="js/global_data.js"></script>
    <!-- Fonts -->
    <link href='http://fonts.googleapis.com/css?family=Roboto+Condensed:300,400' rel='stylesheet' type='text/css'>
    <link href='http://fonts.googleapis.com/css?family=Lato:300,400,700,900' rel='stylesheet' type='text/css'>
    <!-- CSS Libs -->
    <link rel="stylesheet" type="text/css" href="backstage/lib/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="backstage/lib/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="backstage/lib/css/animate.min.css">
    <link rel="stylesheet" type="text/css" href="backstage/lib/css/bootstrap-switch.min.css">
    <link rel="stylesheet" type="text/css" href="backstage/lib/css/checkbox3.min.css">
    <link rel="stylesheet" type="text/css" href="backstage/lib/css/jquery.dataTables.min.css">
    <link rel="stylesheet" type="text/css" href="backstage/lib/css/dataTables.bootstrap.css">
    <link rel="stylesheet" type="text/css" href="backstage/lib/css/select2.min.css">
    <!-- CSS App -->
    <link rel="stylesheet" type="text/css" href="backstage/css/style.css">
    <link rel="stylesheet" type="text/css" href="backstage/css/themes/flat-blue.css">
    <link rel="stylesheet" type="text/css" href="css/sweet-alert.css">
    <script src="https://cdn.bootcdn.net/ajax/libs/axios/0.19.2/axios.min.js"></script>
    <style>
        input:focus{
            border-color: skyblue !important;
            outline: 0;
            -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px skyblue;
            box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px skyblue;
            text-shadow: none;
            caret-color: rgba(0,0,0,0.2);
        }
        .myinput {
            height: 5%;
            border-radius: 6px;
            text-indent: 10px;
            border: 1px solid rgba(0,0,0,0.2);
        }
    </style>

</head>
<canvas id="cas" style="position: absolute;z-index : 0 "></canvas>
<body class="flat-blue">
<div class="app-container">
    <div class="row content-container">
        <nav class="navbar navbar-default navbar-fixed-top navbar-top">
            <div class="container-fluid">
                <div class="navbar-header">
                    <button type="button" class="navbar-expand-toggle">
                        <i class="fa fa-bars icon"></i>
                    </button>
                    <ol class="breadcrumb navbar-breadcrumb">
                        <li class="active">个人信息</li>
                    </ol>
                    <button type="button" class="navbar-right-expand-toggle pull-right visible-xs">
                        <i class="fa fa-th icon"></i>
                    </button>
                </div>
                <ul class="nav navbar-nav navbar-right">
                    <button type="button" class="navbar-right-expand-toggle pull-right visible-xs">
                        <i class="fa fa-times icon"></i>
                    </button>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-bell-o"></i></a>
                        <ul class="dropdown-menu animated fadeInDown">
                            <li class="title">
                                系统通知 <span class="badge pull-right">0</span>
                            </li>
                            <li class="message">
                                没有新消息
                            </li>
                        </ul>
                    </li>
                    <li class="dropdown danger">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-users"></i> 4</a>
                        <ul class="dropdown-menu danger  animated fadeInDown">
                            <li class="title">
                                好友列表 <span class="badge pull-right">3</span>
                            </li>
                            <li>
                                <ul class="list-group notifications">
                                    <a href="#">
                                        <li class="list-group-item">
                                            <span class="badge">1</span> <i class="fa fa-mars icon"></i> 吴永康
                                        </li>
                                    </a>
                                    <a href="#">
                                        <li class="list-group-item">
                                            <span class="badge success">1</span> <i class="fa fa-venus icon"></i> 李文俊
                                        </li>
                                    </a>
                                    <a href="#">
                                        <li class="list-group-item">
                                            <span class="badge danger">2</span> <i class="fa fa-comments icon"></i> customers messages
                                        </li>
                                    </a>
                                    <a href="#">
                                        <li class="list-group-item message">
                                            view all
                                        </li>
                                    </a>
                                </ul>
                            </li>
                        </ul>
                    </li>
                    <li class="dropdown profile">
                        <a href="#" id="LoginOutTitleName" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><span class="caret"></span></a>
                        <ul class="dropdown-menu animated fadeInDown">
                            <li class="profile-img">
                                <img src="backstage/img/profile/picjumbo.com_HNCK4153_resize.jpg" class="profile-img">
                            </li>
                            <li>
                                <div class="profile-info">
                                    <h4 class="username" id="LoginOutName"></h4>
                                    <p id="LoginOutEmail"></p>
                                    <div class="btn-group margin-bottom-2x" role="group">
                                        <button onclick="loginOut()" type="button" class="btn btn-default"><i class="fa fa-sign-out"></i> 登出</button>
                                        <script>
                                            function loginOut() {
                                                localStorage.removeItem("userToken");
                                                window.location="login.html";
                                            }
                                        </script>
                                    </div>
                                </div>
                            </li>
                        </ul>
                    </li>
                </ul>
            </div>
        </nav>
        <div class="side-menu sidebar-inverse">
            <nav class="navbar navbar-default" role="navigation">
                <div class="side-menu-container">
                    <div class="navbar-header">
                        <a class="navbar-brand" href="#">
                            <div class="icon fa fa-cloud"></div>
                            <div class="title">问题反馈</div>
                        </a>
                        <button type="button" class="navbar-expand-toggle pull-right visible-xs">
                            <i class="fa fa-times icon"></i>
                        </button>
                    </div>
                    <ul class="nav navbar-nav">
                        <!-- 被选中的框-->
                        <li class="active">
                            <a href="userMessage.html">
                                <span class="icon fa fa-user"></span><span class="title">个人信息</span>
                            </a>
                        </li>
                        <li>
                            <a href="CodeAndCode.html">
                                <span class="icon fa fa-file-code-o"></span><span class="title">代码对弈</span>
                            </a>
                        </li>

                        <li>
                            <a href="RobotLode.html">
                                <span class="icon fa fa-android"></span><span class="title">人机对弈</span>
                            </a>
                        </li>
                        <!--  提交列表-->
                        <li>
                            <a href="SubmitList.html">
                                <span class="icon fa fa-list"></span><span class="title">提交列表</span>
                            </a>
                        </li>

                        <!-- 赛事-->
                        <li>
                            <a href="UserMatch.html">
                                <span class="icon glyphicon glyphicon-stats"></span><span class="title">赛事</span>
                            </a>
                        </li>

                    </ul>
                </div>
                <!-- /.navbar-collapse -->
            </nav>
        </div>



        <!-- Main Content -->
        <div class="container-fluid">
            <div id="mainArea" class="side-body padding-top">

                <!-- 展示user message时使用的界面***********************begin-->
                <div class="no-margin-bottom row" id="ShowUserMessage">
                    <div class="col-lg-3"></div>
                    <div class="col-lg-6">
                        <div class="well" style="background-color: white;opacity: 0.9;display: flex;border-radius: 7px;border-left:solid 13px rgba(67,67,67,1.00);height: 13vh">
                            <img src="backstage/img/15161740025286421.jpg" height="100%" width="11%" style="border-radius: 100%">
                            <div style="left: 5%;position: relative">
                                <p id="ShowTitleName" style="font-family: 幼圆;font-size: 22px"></p>
                                <p id="ShowPersonalWord" style="font-family: 华文行楷;font-size: 18px;padding-top: 5%">这个人很懒，什么都没有留下……</p>
                            </div>
                        </div>
                        <div class="well" style="background-color: white;opacity: 0.9;height: 76vh">
                            <h4 style="font-family: 幼圆;font-size: 2vh">基本信息<button onclick="ChangeUserMessage();" style="float: right;width: 100px;height: 40px; border-radius: 7px;top:-13px;position: relative" class="btn btn-info"><i class="fa fa-pencil"></i>&nbsp;&nbsp;编辑&nbsp;&nbsp;</button></h4>

                            <hr style="width: 100%;height: 1vh" />
                            <div style="display: flex"><div style="width: 42%;position: relative;font-family: 幼圆;font-size: 2vh;" align="right">昵称：</div><span id="ShowName" style=";color: #8c8c8c;font-family: 幼圆;margin-left: 13%;font-size: 2vh;"></span></div>
                            <hr style="width: 100%;height: 1vh"/>
                            <div style="display: flex"><div style="width: 42%;position: relative;font-family: 幼圆;font-size: 2vh;" align="right">邮箱：</div><span id="ShowEmail" style=";color: #8c8c8c;font-family: 幼圆;margin-left: 13%;font-size: 2vh;"></span></div>
                            <hr style="width: 100%;height: 1vh"/>
                            <div style="display: flex"><div style="width: 42%;position: relative;font-family: 幼圆;font-size: 2vh;" align="right">真实姓名：</div><span id="ShowRealName" style=";color: #8c8c8c;font-family: 幼圆;margin-left: 13%;font-size: 2vh;"></span></div>
                            <hr style="width: 100%;height: 1vh"/>
                            <div style="display: flex"><div style="width: 42%;position: relative;font-family: 幼圆;font-size: 2vh;" align="right">性别：</div><span id="ShowSex" style=";color: #8c8c8c;font-family: 幼圆;margin-left: 13%;font-size: 2vh;"></span></div>
                            <hr style="width: 100%;height: 1vh"/>
                            <div style="display: flex"><div style="width: 42%;position: relative;font-family: 幼圆;font-size: 2vh;" align="right">居住地：</div><span id="ShowPosition" style=";color: #8c8c8c;font-family: 幼圆;margin-left: 13%;font-size: 2vh;"></span></div>
                            <hr style="width: 100%;height: 1vh"/>
                            <div style="display: flex"><div style="width: 42%;position: relative;font-family: 幼圆;font-size: 2vh;" align="right">学历：</div><span id="ShowEducation" style=";color: #8c8c8c;font-family: 幼圆;margin-left: 13%;font-size: 2vh;"></span></div>
                            <hr style="width: 100%;height: 1vh"/>
                            <div style="display: flex"><div style="width: 42%;position: relative;font-family: 幼圆;font-size: 2vh;" align="right">入学年份：</div><span id="ShowInSchoolYear" style=";color: #8c8c8c;font-family: 幼圆;margin-left: 13%;font-size: 2vh;"></span></div>
                            <hr style="width: 100%;height: 1vh"/>
                        </div>
                    </div>
                    <div class="col-lg-3"></div>
                </div>
                <!-- *************end**************-->

                <!-- 更改user message时使用的界面************************begin-->
                <div class="no-margin-bottom row" id="ChangeUserMessage" style="display: none">
                    <div class="col-lg-3"></div>
                    <div class="col-lg-6">
                        <div class="well" style="background-color: white;opacity: 0.9;display: flex;border-radius: 7px;border-left:solid 13px rgba(67,67,67,1.00);height: 13vh">
                            <img src="backstage/img/15161740025286421.jpg" height="100%" width="11%" style="border-radius: 100%">
                            <div style="left: 5%;position: relative">
                                <p id="ChangeTitleName" style="font-family: 幼圆;font-size: 22px"></p>
                                <p id="ChangeTitlePersonalWord" style="font-family: 华文行楷;font-size: 18px;padding-top: 5%">这个人很懒，什么都没有留下……</p>
                            </div>
                        </div>
                        <div class="well" style="background-color: white;opacity: 0.9;">
                            <h4 style="font-family: 幼圆;font-size: 2vh">基本信息<button onclick="CancelButton()" style="background-color: rgb(180,180,180);border-color:rgb(180,180,180);width: 100px;height: 40px; border-radius: 7px;top:-13px;position: relative;left: 65%" class="btn btn-info"><i class="fa fa-times"></i>&nbsp;&nbsp;取消&nbsp;&nbsp;</button><button onclick="SaveButton()" style="float: right;width: 100px;height: 40px; border-radius: 7px;top:-13px;position: relative" class="btn btn-info"><i class="fa fa-pencil"></i>&nbsp;&nbsp;保存&nbsp;&nbsp;</button></h4>
                            <hr style="width: 100%;height: 1vh" />
                            <span style="font-family: 幼圆;font-size: 2vh;">我的昵称：<input id="ChangeName" class="myinput" style="width: 200px;"></span>
                            <hr style="width: 100%;height: 1vh"/>
                            <span style="font-family: 幼圆;font-size: 2vh;">邮箱：<span id="ChangeEmail"></span></span>
                            <hr style="width: 100%;height: 1vh"/>
                            <span style="font-family: 幼圆;font-size: 2vh;">真实姓名：<input id="ChangeRealName" class="myinput" style="width: 200px;"></span>
                            <hr style="width: 100%;height: 1vh"/>
                            <span style="font-family: 幼圆;font-size: 2vh;">入学年份：<input id="ChangeInSchoolYear" class="myinput" type="date" style="width: 400px;"></span>
                            <hr style="width: 100%;height: 1vh"/>
                            <span style="font-family: 幼圆;font-size: 2vh;">性别：<button id="i4" class="btn" style="width: 160px;background-color: rgb(180,180,180);border-color:rgb(180,180,180);color: white;left: 45px;border-radius: 8px;font-size: 2vh;position: relative">&nbsp;&nbsp;&nbsp;<i class="fa fa-mars"></i>&nbsp;&nbsp;&nbsp;男&nbsp;&nbsp;&nbsp;</button>
								<button id="i5" class="btn" style="width: 160px;background-color: rgb(180,180,180);border-color:rgb(180,180,180);color: white;position: relative;left: 110px;border-radius: 8px;font-size: 2vh">&nbsp;&nbsp;&nbsp;<i class="fa fa-venus"></i>&nbsp;&nbsp;&nbsp;女&nbsp;&nbsp;&nbsp;</button></span>

                            <hr style="width: 100%;height: 1vh"/>
                            <span style="font-family: 幼圆;font-size: 2vh;">个性签名：<input id="ChangePersonalWord" class="myinput" style="width: 400px;"></span>
                            <hr style="width: 100%;height: 1vh"/>
                            <span style="font-family: 幼圆;font-size: 2vh;">学历：<select id="ChangeEducation" class="myinput" style="left: 4.5%;position: relative;width:200px;padding: 0 6%">
                                        <option>高中</option>
                                        <option>大学</option>
                                        <option>研究生</option>
                                        <option>博士</option>
                                        <option>其它</option>
                                    </select>
								</span>
                            <hr style="width: 100%;height: 1vh"/>
                            <span style="font-family: 幼圆;font-size: 2vh;">居住地：<input id="ChangePosition" class="myinput" style="left: 2.5%;position: relative;width: 200px;"></span>
                        </div>

                    </div>
                    <div class="col-lg-3"></div>

                </div>
                <!-- ****************************************end***********************-->

            </div>
        </div>
    </div>

    <!-- Javascript Libs -->
    <script src="js/sweet-alert.js"></script>
    <script type="text/javascript" src="backstage/lib/js/jquery.min.js"></script>
    <script type="text/javascript" src="backstage/lib/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="backstage/lib/js/Chart.min.js"></script>
    <script type="text/javascript" src="backstage/lib/js/bootstrap-switch.min.js"></script>
    <script type="text/javascript" src="backstage/lib/js/jquery.matchHeight-min.js"></script>
    <script type="text/javascript" src="backstage/lib/js/jquery.dataTables.min.js"></script>
    <script type="text/javascript" src="backstage/lib/js/dataTables.bootstrap.min.js"></script>
    <script type="text/javascript" src="backstage/lib/js/ace/ace.js"></script>
    <script type="text/javascript" src="backstage/lib/js/ace/mode-html.js"></script>
    <script type="text/javascript" src="backstage/lib/js/ace/theme-github.js"></script>
    <!-- Javascript -->
    <script type="text/javascript" src="backstage/js/app.js"></script>
    <script type="text/javascript" src="backstage/js/index.js"></script>
    <script type="text/javascript" src="js/userMessage.js"></script>
</div></body>


<script>
    let userMessage={};
    LodeUserMessage();

    //点击编辑按钮后的加载函数
    function ChangeUserMessage() {
        document.getElementById("ChangeName").value = userMessage.name;
        document.getElementById("ChangeRealName").value = userMessage.realName;
        document.getElementById("ChangeInSchoolYear").value = userMessage.inSchoolYear;
        document.getElementById("ChangePosition").value = userMessage.position;
        document.getElementById("ChangePersonalWord").value = userMessage.personalWord;
        document.getElementById("ChangeEducation").value = userMessage.education;
        if(userMessage.sex === "男")
            $("#i4").click();
        else
            $("#i5").click();
        if(userMessage.personalWord != null) {
            document.getElementById("ChangeTitlePersonalWord").innerText = userMessage.personalWord;
        }
        document.getElementById("ChangeTitleName").innerText = userMessage.name;
        document.getElementById("ChangeEmail").innerText = userMessage.email;
        document.getElementById("ShowUserMessage").style.display = "none";
        document.getElementById("ChangeUserMessage").style.display = "";
    }

    //取消按钮绑定的函数
    function CancelButton() {
        document.getElementById("ShowUserMessage").style.display = "";
        document.getElementById("ChangeUserMessage").style.display = "none";
    }

    function SaveButton() {
        var name = document.getElementById("ChangeName").value;
        var email = userMessage.email;
        var realName = document.getElementById("ChangeRealName").value;
        var inSchoolYear = document.getElementById("ChangeInSchoolYear").value;
        var position = document.getElementById("ChangePosition").value;
        var personalWord = document.getElementById("ChangePersonalWord").value;
        var education = document.getElementById("ChangeEducation").value;
        var sex;
        if(lflag === 0) {
            sex = "男"
        } else {
            sex = "女";
        }
        name = '{"name":"'+name+'","email":"'+email+'","realName":"'+realName+'","inSchoolYear":"'+inSchoolYear
                +'","position":"'+position+'","personalWord":"'+personalWord+'","education":"'+education+'","sex":"'+sex+'"}';
        $.ajax({
            async: false,
            type: "post",
            url: serverIpAddress+"User/SaveUserMessage",
            data: name,
            contentType: "application/json;charset=utf-8",
            dataType: "json",
            success:function (data) {
                localStorage.setItem("userToken",data.userToken);
            }
        });
        swal("成功","信息已保存","success");
        $("button").click(function () {
            window.location.reload();
        })
    }

    async function LodeUserMessage() {
        await axios.post(serverIpAddress+"User/LodeUserMessage", {"userToken":localStorage.getItem("userToken")}).then((res) => {
            if(res.data==null||res.data=="") {
                window.location="login.html";
            }
            userMessage=res.data;
        });
        if(userMessage.personalWord != null) {
            document.getElementById("ShowPersonalWord").innerText = userMessage.personalWord;
        }
        if(userMessage.realName == null)
            userMessage.realName = "未填写";
        if(userMessage.position == null)
            userMessage.position = "未填写";
        if(userMessage.sex == null)
            userMessage.sex = "未填写";
        if(userMessage.education == null)
            userMessage.education = "未填写";
        if(userMessage.inSchoolYear == null)
            userMessage.inSchoolYear = "未填写";
        document.getElementById("ShowTitleName").innerText = userMessage.name;
        document.getElementById("ShowName").innerText += userMessage.name;
        document.getElementById("ShowEmail").innerText += userMessage.email;
        document.getElementById("ShowPosition").innerText += userMessage.position;
        document.getElementById("ShowRealName").innerText += userMessage.realName;
        document.getElementById("ShowSex").innerText += userMessage.sex;
        document.getElementById("ShowEducation").innerText += userMessage.education;
        document.getElementById("ShowInSchoolYear").innerText += userMessage.inSchoolYear;
        $("#LoginOutTitleName").html(userMessage.name+"<span class=\"caret\"></span>");
        $("#LoginOutName").html(userMessage.name);
        $("#LoginOutEmail").html(userMessage.email);
    }


    var lflag=1,rflag=1;
    $("#i4").mouseover(function(){
        $("#i4").css("background-color","rgb(131,196,119)");
        $("#i4").css("border-color","rgb(131,196,119)");
    })
    $("#i4").click(function(){
        $("#i4").css("background-color","rgb(131,196,119)");
        $("#i4").css("border-color","rgb(131,196,119)");
        lflag=0;
        rflag=1;
        $("#i5").css("background-color","rgb(180,180,180)");
        $("#i5").css("border-color","rgb(180,180,180)");
    })
    $("#i4").mouseout(function(){
        if(lflag==1) {
            $("#i4").css("background-color","rgb(180,180,180)");
            $("#i4").css("border-color","rgb(180,180,180)");
        }
    })
    $("#i5").mouseover(function(){
        $("#i5").css("background-color","rgb(231,115,163)");
        $("#i5").css("border-color","rgb(231,115,163)");
    })
    $("#i5").click(function(){
        $("#i5").css("background-color","rgb(231,115,163)");
        $("#i5").css("border-color","rgb(231,115,163)");
        rflag=0;
        lflag=1;
        $("#i4").css("background-color","rgb(180,180,180)");
        $("#i4").css("border-color","rgb(180,180,180)");
    })
    $("#i5").mouseout(function(){
        if(rflag==1) {
            $("#i5").css("background-color","rgb(180,180,180)");
            $("#i5").css("border-color","rgb(180,180,180)");
        }
    })
</script>


</html>

